package mid

/*
* @author: hjz
* @time: 2025/6/5 22:08
* @desc:53. 最大子数组和
 */
func maxSubArray(nums []int) int {
	if len(nums) == 0 {
		return 0
	}
	maxSum := nums[0]
	currentSum := nums[0]
	for i := 1; i < len(nums); i++ {
		currentSum = maxT(nums[i], currentSum+nums[i])
		maxSum = maxT(maxSum, currentSum)
	}
	return maxSum
}
